import cv2
import os


def get_edge_image(path):
    """

    :param path: 图片地址
    :return:
    """
    img = cv2.imread(path)
    edges = cv2.Canny(img, 1, 256)
    cv2.imshow("edges2", edges)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    pass


def get_shape(path):
    """

    :param path: 图片地址
    :return:
    """
    img = cv2.imread(path)
    print(img.shape)


def delete(path):
    """

    :param path: 图片地址
    :return:
    """
    if path.find("rr-") != -1:
        print(path)
        os.remove(path)
    if path.find("&") != -1:
        print(path)
        os.remove(path)
    pass


def loop(path, function=get_shape):
    """

    :param function:
    :param path:  目录
    :return:
    """
    for c_root, c_dirs, c_files in os.walk(path):
        for file in c_files:
            # 获取文件路径
            if file.endswith(".avi"):
                function(os.path.join(c_root, file))


if __name__ == "__main__":
    # loop(r"D:\dataset\YawDDdataset\Mirror", get_shape)
    # loop(r"D:\dataset\YawDDdataset\Mirror", get_edge_image)
    loop(r"/home/zy/dataset/yawDD/Female_mirror", delete)
    loop(r"/home/zy/dataset/yawDD/Male_mirror", delete)
